package org.bmind.datasword.config.dto;

import org.bmind.datasword.utils.EqualsUtil;
import org.bmind.datasword.utils.HashCodeUtil;
import org.bmind.datasword.utils.StorageUtilities;

public class DData extends DObjCommon
{
	/**
     * 
     */
    private static final long serialVersionUID = 1L;

	static { StorageUtilities.addREngineType(DData.class); }
	private int fHashCode ;
	private DFunctionType fType = null;
	//public DData(){	}
	
	public DFunctionType getfType() {return fType;}
	public void setfType(DFunctionType fType) {this.fType = fType;}

	/* (non-Javadoc)
     * @see org.bmind.datasword.config.dto.DObjCommon#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if ( this == obj ) return true;
 	    if ( !(obj instanceof DData) ) return false;
 	   
 	    DData dDt = (DData)obj;
     	
     	return	EqualsUtil.areEqual(this.name, dDt.name) &&
     			EqualsUtil.areEqual(this.label, dDt.label) &&
     			EqualsUtil.areEqual(this.hint, dDt.hint) &&
     			EqualsUtil.areEqual(this.exec, dDt.exec) &&
     			EqualsUtil.areEqual(this.visible, dDt.visible) &&
     			EqualsUtil.areEqual(this.dEngineType, dDt.dEngineType) &&
     			EqualsUtil.areEqual(this.fParameter, dDt.fParameter) &&
     			EqualsUtil.areEqual(this.Library, dDt.Library) &&
     			EqualsUtil.areEqual(this.getfType(), dDt.getfType()) &&
     			EqualsUtil.areEqual(this.getfParameter(), dDt.getFunction()) &&
     			EqualsUtil.areEqual(this.getAreas(), dDt.getAreas()) &&
     			EqualsUtil.areEqual(this.getRoles(), dDt.getRoles()) &&
     			EqualsUtil.areEqual(this.getFunction(), dDt.getFunction()) &&
     			EqualsUtil.areEqual(this.getID(), dDt.getID()) &&
     			EqualsUtil.areEqual(this.getNextId(), dDt.getNextId()) &&
     			EqualsUtil.areEqual(this.getPreviusId(), dDt.getPreviusId()) && 
     			EqualsUtil.areEqual(this.getVersion(), dDt.getVersion());
    }

	/* (non-Javadoc)
     * @see org.bmind.datasword.config.dto.DObjCommon#hashCode()
     */
	@Override
	public int hashCode() {
		
		// this style of lazy initialization is
		// suitable only if the object is immutable
		if (fHashCode == 0) {
		int result = HashCodeUtil.SEED;
			result = HashCodeUtil.hash(result, getID());
			result = HashCodeUtil.hash(result, getNextId());
			result = HashCodeUtil.hash(result, getPreviusId());
			result = HashCodeUtil.hash(result, getAreas());
			result = HashCodeUtil.hash(result, getRoles());
			result = HashCodeUtil.hash(result, getEngineType());
			result = HashCodeUtil.hash(result, getfParameter());
			result = HashCodeUtil.hash(result, getLabel());
			result = HashCodeUtil.hash(result, getLibrary());
			result = HashCodeUtil.hash(result, getFunction());
			result = HashCodeUtil.hash(result, getfType());
			result = HashCodeUtil.hash(result, getLabel());
			result = HashCodeUtil.hash(result, getHint());
			result = HashCodeUtil.hash(result, getVisible());
			fHashCode = result;
		}
		return fHashCode;
	}
	
	
}
